package com.lagou.service;

import com.baomidou.mybatisplus.core.MybatisSqlSessionFactoryBuilder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lagou.config.Config;
import com.lagou.mapper.AccountMapper;
import com.lagou.pojo.Account;

/**
 * @Authther: mrwu
 * @date:2021/3/12-03
 * @Description:com.lagou.service
 */
public class AccountServiceImpl implements AccountService{
    private Config config = new Config();
    private AccountMapper accountMapper = config.getSqlSession().getMapper(AccountMapper.class);
    @Override
    public void transfer(String fromNo, String toNo,int money)throws Exception {

        Account from = accountMapper.selectObjByCardNo(fromNo);
        Account to = accountMapper.selectObjByCardNo(toNo);
        from.setMoney(from.getMoney()-money);
        to.setMoney(to.getMoney()+money);
        accountMapper.updateAccountBycardNo(from);
        accountMapper.updateAccountBycardNo(to);
    }
}
